package com.zhengqing.design.action.interpreter._01;

import com.zhengqing.design.action.interpreter._01.expression.Expression;

import java.util.HashMap;
import java.util.Map;

/**
 * <p> 环境类，存储解释器之外的一些全局信息，通常它临时存储了需要解释的语句 </p>
 *
 * @author zhengqingya
 * @description
 * @date 2022/12/22 13:52
 */
public class Context {
    private Map<Expression, Integer> map = new HashMap<>();

    public void add(Expression s, Integer value) {
        this.map.put(s, value);
    }

    public int lookup(Expression s) {
        // 将变量转换成数字
        return this.map.get(s);
    }
}
